#ifndef QMEMERYDATAEDITOR_H
#define QMEMERYDATAEDITOR_H

#include <QDialog>
#include <QItemDelegate>
#include <QTreeWidgetItem>

namespace Ui {
class QMemeryDataEditor;
}

namespace SHAREDLIB
{
    class QAbstractProperty;
}

class QMemeryDataEditor;

class QMemeryDelegate: public QItemDelegate
{
    Q_OBJECT
public :
    QMemeryDelegate(QMemeryDataEditor* editor):m_editor(editor){}
    QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
    void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const;
    void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
    QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
    void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
    void setEditorData(QWidget *editor, const QModelIndex &index) const;
protected:
    QMemeryDataEditor   *m_editor;
};


class QMemeryDataEditor : public QDialog
{
    Q_OBJECT
    
public:
    explicit QMemeryDataEditor(SHAREDLIB::QAbstractProperty *property);
    ~QMemeryDataEditor();

protected:
    SHAREDLIB::QAbstractProperty    *m_property;
private slots:
    void on_cancelBtn_clicked();

    void on_addBtn_clicked();

    void on_delBtn_clicked();

    void on_okBtn_clicked();
protected:
    friend class QMemeryDelegate;
    Ui::QMemeryDataEditor *ui;
    QList<QTreeWidgetItem*> m_items;
};

#endif // QMEMERYDATAEDITOR_H
